<include file="Public/mobile_head"/>
<include file="./Addons/Shop/View/default/Index/base.html" />
<body >
<!--顶部搜索-->
<include file="./Addons/Shop/View/default/Index/header.html" />
<!--END 顶部搜索 -->

<!--底部导航-->
<include file="./Addons/Shop/View/default/Index/footer.html" />
<!--END 底部导航-->
<section id="selector">
		
	<div class="order w100p">
		<ul class="w33" id="sort_top">
                    <li><a href="{:addons_url('Shop://Index/searchlist',array('ordertype'=>'default','cate_id'=>$cate_id,'search_val'=>$search_val))}" <eq name="ordertype" value="default">class="current" style="border-bottom-color:#{$shop_config.color}; color:#{$shop_config.color}"</eq>>默认</a></li>
                        <li><a href="{:addons_url('Shop://Index/searchlist',array('ordertype'=>'sellnum','cate_id'=>$cate_id,'search_val'=>$search_val))}" <eq name="ordertype" value="sellnum">class="current" style="border-bottom-color:#{$shop_config.color}; color:#{$shop_config.color}"</eq>>销量</a></li>
			<li><a href="{:addons_url('Shop://Index/searchlist',array('ordertype'=>'price','cate_id'=>$cate_id,'search_val'=>$search_val))}" <eq name="ordertype" value="price">class="current" style="border-bottom-color:#{$shop_config.color}; color:#{$shop_config.color}"</eq>>价格</a></li>
		</ul>
	</div>
</section>
<section id="goods-list">
	<ul>
               <volist name="list" id="vo_list">
                    <li class="clear pr">
                        <a href="{:addons_url('Shop://Index/productinfo',array('id'=>$vo_list['id']))}">
                                     <span class="image l mr10"><img src="{$vo_list.head_img|get_cover_url}" alt=""></span>
                                     <div class="product_title fl">{$vo_list.name}</div>
                                     <div class="price f1-6 fb fl mt_10">￥{$vo_list.true_price}</div>
                                     <del class="c9 fl ml_10 mt_10">￥{$vo_list.old_price}</del>
                                     <div class="c9 sale_num">已售出 {$vo_list.sellnum} 件</div>
                                     <a href="#" class="addcar" onclick="addcart(this);;return false;" url="{:addons_url('Shop://Cart/inCart',array('id'=>$vo_list['id']))}" ></a>
                             </a>
                             <div class="btn pa">
                                     <a href="#" class="add2fav"><img src="{:ADDON_PUBLIC_PATH}/images/icon-fav.png" alt="收藏"></a>
                                     <a href="#" class="add2car"><img src="{:ADDON_PUBLIC_PATH}/images/icon-car.png" alt="添加到购物车"></a>
                             </div>
                     </li>
                </volist>
		
	</ul>
</section>
<section id="loading" class="listloading">
    <gt name="pageinfo.num" value="1">数据加载中...</gt>
</section>
<!--底部 版权信息--> 
<include file="./Addons/Shop/View/default/Index/footerbq.html" /> 
<!--END 底部导航-->
</body>
<script src="{:ADDON_PUBLIC_PATH}/js/jquery.js"></script>
<script src="{:ADDON_PUBLIC_PATH}/js/swiper.js"></script>
<script src="{:ADDON_PUBLIC_PATH}/js/comm.js"></script>
<script>
function addcart(me){
    var url = $(me).attr('url');
    $.ajax({
        url:url,
        type:"get",
        dataType:"json",
        success:function(re){
            if(re){
                cartNum(re);
                alert('已添加进购物车');
            }else{
                alert('添加失败');
            }
        },
        error:function(){
            alert('添加失败');
        }
    });
    return false;
}
$(function(){
        var num = 2;
        var cate_id = "{$cate_id}";
        $(window).scroll(function(){ 
            totalheight = parseFloat($(window).height()) + parseFloat($(window).scrollTop()); 
            if($(document).height() <= totalheight){
                loadPage();
            } 
        });
        
        function loadPage(){
                $('#loading').show();
                var search_val = $('#search_val').val();
                var jsondata='{"p":"'+num+'","cate_id":"'+cate_id+'","search_val":"'+search_val+'"}';
                jsondata=$.parseJSON(jsondata);
		$.ajax({
			url:"{:addons_url('Shop://Index/searchlist')}",
			type:'POST',
			dataType:'json',
                        data:jsondata,
			success: function(data){
                            var html = '';
                            $(data).each(function(){
                                 html += '<li class="clear pr">'+
                                            '<a href="'+$(this)[0]['url']+'">'+
                                                '<span class="image l mr10"><img src="'+$(this)[0]['head_img']+'" alt=""></span>'+
                                                '<div class="product_title fl">'+$(this)[0]['name']+'</div>'+
                                                '<div class="price f1-6 fb fl mt_10">￥'+$(this)[0]['true_price']+'</div>'+
                                                '<del class="c9 fl ml_10 mt_10">￥'+$(this)[0]['old_price']+'</del>'+
                                                '<div class="c9 sale_num">已售出 '+$(this)[0]['sellnum']+'件</div>'+
                                                '<a href="#" class="addcar" onclick="addcart(this);return false;" url="{:addons_url('Shop://Cart/inCart')}&id='+$(this)[0]['id']+'" ></a>'+
                                    '</a>'+
                                    '<div class="btn pa">'+
                                        '<a href="#" class="add2fav"><img src="{:ADDON_PUBLIC_PATH}/images/icon-fav.png" alt="收藏"></a>'+
                                        '<a href="#" class="add2car"><img src="{:ADDON_PUBLIC_PATH}/images/icon-car.png" alt="添加到购物车"></a>'+
                                    '</div>'+
                                 '</li>';
                            })
                            num = num + 1;
                            $('#loading').hide();
                            $('#goods-list ul').append(html);
                                
			},
			error:function(){
                            $('#loading').hide();
                            alert('数据加载失败')
			}
		})
	};
        
	$('p.more').click(function(){
		if($('em',this).hasClass('open')){
			$('em',this).removeClass('open');
			$('.cate-more').slideUp()
		}else{
			$('em',this).addClass('open');
			$('.cate-more').slideDown()
		}
	});
	$('.add2car').click(function(){
            var cont='<center class="f1-4 mb10">添加成功</center><ul class="w50"><li><a href="shopcar-list.html" class="btn-red">查看购物车</a></li><li><div class="ml10"><a href="#" class="btn-grey" onclick="return KmPop.hide()">继续购物</a></div></li></ul>';
            KmPop.init(cont);
            return false
	});
       
	$('.add2fav').click(function(){
		var $this=$('img',this);
		if($this.attr('src').indexOf('fav2')>0){
			var cont='<center class="f1-4 mb10">已加入我的收藏了哦，亲~</center><ul class="w50"><li><a href="user-fav.html" class="btn-red">去收藏夹看看</a></li><li><div class="ml10"><a href="#" class="btn-grey" onclick="return KmPop.hide()">点错了</a></div></li></ul>';
			KmPop.init(cont)
		}else{
			$this.addClass('add2favui');
			setTimeout(function(){
				$this.removeClass('add2favui').attr('src','images/icon-fav2.png')
			},500)
		};
		return false
	});
        
        //顶部效果
        /*
        $('#sort_top li').click(function(){
            $(this).parent().find('a').removeClass('current');
            $(this).find('a').addClass('current');
            return false;
        })
	
	$(window).scroll(function(){
		$(document).height()-$(this).scrollTop()-$(window).height()<50?loadPage():true
	})*/
})
</script>
</html>
